package com.vodafone.nocs.inops.tools.fix;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class BundleInfo {
	
	private String bundleId;
	private String startDate;
	private String endDate;
	private String bucket;
	private int placeInQueue;
	private boolean queued;

	
	public String getBundleId() {
		return bundleId;
	}
	public void setBundleId(String bundleId) {
		this.bundleId = bundleId;
	}
	public String getStartDate() {
		return startDate;
	}
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getBucket() {
		return bucket;
	}
	public void setBucket(String bucket) {
		this.bucket = bucket;
	}
	public int getPlaceInQueue() {
		return placeInQueue;
	}
	public void setPlaceInQueue(int placeInQueue) {
		this.placeInQueue = placeInQueue;
	}
//	public BundleInfo(String bundleId, String startDate, String endDate, String bucket) {
//		super();
//		this.bundleId = (bundleId);
//		this.startDate = (startDate);
//		this.endDate = (endDate);
//		this.bucket = (bucket);
//
//	}
	public BundleInfo() {
		super();
		// TODO Auto-generated constructor stub
	}
	public boolean isQueued() {
		return queued;
	}
	public void setQueued(boolean queued) {
		this.queued = queued;
	}
	
	public boolean hasExpired(){
		boolean expired = false;
		if (this.getEndDate() != null && this.getEndDate().length() > 0) {
			try{
				SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
				Date edate = formatter.parse(this.getEndDate());
				
				Calendar cal = Calendar.getInstance();
				cal.add(Calendar.DATE, -1);
				expired = edate.before(cal.getTime());
			}
			
			catch (ParseException e) {
				UTIL.OUTLOG("# Unexpected end date "+e.getMessage());

			}
			if (expired)
				UTIL.OUTLOG("# End date ("+this.getEndDate()+") already passed, bundle ["+ this.getBundleId() +"] will not be reprovisioned"); 
		}
		return expired;
	}
	
}
